/*
     This file is part of Power Reader.

    Power Reader is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Power Reader is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Power Reader.  If not, see <http://www.gnu.org/licenses/>. 
    
    This software was developed by members of Project:Possibility, a software 
    collaboration for the disabled.
    
    For more information, visit http://www.projectpossibility.org 
 */

package powerreader;

import util.TextObject3d;

/**
 *
 * @author  Christopher Leung
 */
public class OptionsUI extends javax.swing.JDialog {
    
    /** Creates new form OptionsUI */
    public OptionsUI(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        m_combo_dictionaryLookup = new javax.swing.JComboBox();
        m_combo_imageLookup = new javax.swing.JComboBox();
        m_combo_fontFace = new javax.swing.JComboBox();
        m_combo_voicePersonality = new javax.swing.JComboBox();
        m_combo_leftClick = new javax.swing.JComboBox();
        m_combo_middleClick = new javax.swing.JComboBox();
        m_combo_rightClick = new javax.swing.JComboBox();
        m_okButton = new javax.swing.JButton();
        m_cancelButton = new javax.swing.JButton();
        m_checkBox_mouseWheel = new javax.swing.JCheckBox();
        m_label_dictionarySource = new javax.swing.JLabel();
        m_label_imageSource = new javax.swing.JLabel();
        m_label_fontFace = new javax.swing.JLabel();
        m_label_voicePersonality = new javax.swing.JLabel();
        m_label_leftClick = new javax.swing.JLabel();
        m_label_middleClick = new javax.swing.JLabel();
        m_label_rightClick = new javax.swing.JLabel();
        m_label_rightClick1 = new javax.swing.JLabel();
        m_slider_lineWidth = new javax.swing.JSlider();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        m_slider_textDepth = new javax.swing.JSlider();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Power Reader Options");
        m_combo_dictionaryLookup.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Wiktionary", "WordNet Dictionary" }));

        m_combo_imageLookup.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Flickr", "Google Images", "Yahoo Images" }));

        m_combo_fontFace.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tahoma" }));

        m_combo_voicePersonality.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kevin" }));
        m_combo_voicePersonality.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_combo_voicePersonalityActionPerformed(evt);
            }
        });

        m_combo_leftClick.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Focus on item", "Drag and scroll", "Read dictionary definition", "Do nothing" }));

        m_combo_middleClick.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Focus on item", "Drag and scroll", "Read dictionary definition", "Do nothing" }));
        m_combo_middleClick.setSelectedIndex(2);

        m_combo_rightClick.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Focus on item", "Drag and scroll", "Read dictionary definition", "Do nothing" }));
        m_combo_rightClick.setSelectedIndex(1);

        m_okButton.setText("OK");
        m_okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_okButtonActionPerformed(evt);
            }
        });

        m_cancelButton.setText("Cancel");
        m_cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                m_cancelButtonActionPerformed(evt);
            }
        });

        m_checkBox_mouseWheel.setSelected(true);
        m_checkBox_mouseWheel.setText("Enable Mouse Wheel Zoom");
        m_checkBox_mouseWheel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        m_checkBox_mouseWheel.setMargin(new java.awt.Insets(0, 0, 0, 0));

        m_label_dictionarySource.setFont(new java.awt.Font("Tahoma", 1, 11));
        m_label_dictionarySource.setText("Dictionary Source");

        m_label_imageSource.setFont(new java.awt.Font("Tahoma", 1, 11));
        m_label_imageSource.setText("Image Source");

        m_label_fontFace.setFont(new java.awt.Font("Tahoma", 1, 11));
        m_label_fontFace.setText("Font Face");

        m_label_voicePersonality.setFont(new java.awt.Font("Tahoma", 1, 11));
        m_label_voicePersonality.setText("Voice Personality");

        m_label_leftClick.setFont(new java.awt.Font("Tahoma", 1, 11));
        m_label_leftClick.setText("Left Click");

        m_label_middleClick.setFont(new java.awt.Font("Tahoma", 1, 11));
        m_label_middleClick.setText("Middle Click");

        m_label_rightClick.setFont(new java.awt.Font("Tahoma", 1, 11));
        m_label_rightClick.setText("Right Click");

        m_label_rightClick1.setFont(new java.awt.Font("Tahoma", 1, 11));
        m_label_rightClick1.setText("Line Width ");
        m_label_rightClick1.setName("Line Width");

        m_slider_lineWidth.setMajorTickSpacing(10);
        m_slider_lineWidth.setMinimum(5);
        m_slider_lineWidth.setMinorTickSpacing(20);
        m_slider_lineWidth.setPaintLabels(true);
        m_slider_lineWidth.setPaintTicks(true);
        m_slider_lineWidth.setValue(20);

        jLabel1.setText("Note: Load a new file for");

        jLabel2.setText("this change to take effect");

        m_slider_textDepth.setMajorTickSpacing(1);
        m_slider_textDepth.setMaximum(10);
        m_slider_textDepth.setMinimum(1);
        m_slider_textDepth.setPaintLabels(true);
        m_slider_textDepth.setPaintTicks(true);
        m_slider_textDepth.setValue(1);
        m_slider_textDepth.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                m_slider_textDepthStateChanged(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setText("Text Depth");

        jLabel4.setText("Sets the 3D Text Depth");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 139, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel2)
                            .add(m_label_rightClick1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 139, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel3)
                            .add(jLabel4)
                            .add(m_label_rightClick)
                            .add(m_label_middleClick)
                            .add(m_label_leftClick)
                            .add(m_label_voicePersonality)
                            .add(m_label_fontFace)
                            .add(m_label_imageSource)
                            .add(m_label_dictionarySource))
                        .add(16, 16, 16)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(m_combo_imageLookup, 0, 182, Short.MAX_VALUE)
                            .add(m_combo_dictionaryLookup, 0, 182, Short.MAX_VALUE)
                            .add(m_combo_fontFace, 0, 182, Short.MAX_VALUE)
                            .add(m_combo_voicePersonality, 0, 182, Short.MAX_VALUE)
                            .add(m_combo_leftClick, 0, 182, Short.MAX_VALUE)
                            .add(m_combo_middleClick, 0, 182, Short.MAX_VALUE)
                            .add(m_combo_rightClick, 0, 182, Short.MAX_VALUE)
                            .add(m_checkBox_mouseWheel)
                            .add(m_slider_lineWidth, 0, 0, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, m_slider_textDepth, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)))
                    .add(layout.createSequentialGroup()
                        .add(m_okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 153, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(m_cancelButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 166, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m_combo_dictionaryLookup, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(m_label_dictionarySource))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m_combo_imageLookup, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(m_label_imageSource))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m_combo_fontFace, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(m_label_fontFace, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m_combo_voicePersonality, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(m_label_voicePersonality))
                .add(29, 29, 29)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m_combo_leftClick, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(m_label_leftClick))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m_combo_middleClick, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(m_label_middleClick))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m_combo_rightClick, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(m_label_rightClick))
                .add(14, 14, 14)
                .add(m_checkBox_mouseWheel)
                .add(23, 23, 23)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(m_slider_lineWidth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(layout.createSequentialGroup()
                        .add(m_label_rightClick1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(14, 14, 14)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jLabel3)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(m_slider_textDepth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(19, 19, 19)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(m_okButton)
                    .add(m_cancelButton))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void m_slider_textDepthStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_m_slider_textDepthStateChanged
        ConfigurationManager.TEXT_DEPTH = m_slider_textDepth.getValue() / 2f;
        ConfigurationManager.currentRoot.color(false);
    }//GEN-LAST:event_m_slider_textDepthStateChanged

    private void m_cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_cancelButtonActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_m_cancelButtonActionPerformed

    private void m_okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_okButtonActionPerformed
        if (m_slider_lineWidth.getValue() != (int)TextObject3d.getLineWidth()) {
            // Set the new line width
            TextObject3d.setLineWidth((float)m_slider_lineWidth.getValue());
        }
        ConfigurationManager.setDictionary(m_combo_dictionaryLookup.getSelectedIndex());
        ConfigurationManager.setImageLookup(m_combo_imageLookup.getSelectedIndex());
        ConfigurationManager.setLeftClickAction(m_combo_leftClick.getSelectedIndex());
        ConfigurationManager.setMiddleClickAction(m_combo_middleClick.getSelectedIndex());
        ConfigurationManager.setRightClickAction(m_combo_rightClick.getSelectedIndex());
        this.setVisible(false);
    }//GEN-LAST:event_m_okButtonActionPerformed

    private void m_combo_voicePersonalityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_combo_voicePersonalityActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_m_combo_voicePersonalityActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new OptionsUI(new javax.swing.JFrame(), true).setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JButton m_cancelButton;
    private javax.swing.JCheckBox m_checkBox_mouseWheel;
    private javax.swing.JComboBox m_combo_dictionaryLookup;
    private javax.swing.JComboBox m_combo_fontFace;
    private javax.swing.JComboBox m_combo_imageLookup;
    private javax.swing.JComboBox m_combo_leftClick;
    private javax.swing.JComboBox m_combo_middleClick;
    private javax.swing.JComboBox m_combo_rightClick;
    private javax.swing.JComboBox m_combo_voicePersonality;
    private javax.swing.JLabel m_label_dictionarySource;
    private javax.swing.JLabel m_label_fontFace;
    private javax.swing.JLabel m_label_imageSource;
    private javax.swing.JLabel m_label_leftClick;
    private javax.swing.JLabel m_label_middleClick;
    private javax.swing.JLabel m_label_rightClick;
    private javax.swing.JLabel m_label_rightClick1;
    private javax.swing.JLabel m_label_voicePersonality;
    private javax.swing.JButton m_okButton;
    private javax.swing.JSlider m_slider_lineWidth;
    private javax.swing.JSlider m_slider_textDepth;
    // End of variables declaration//GEN-END:variables
    
}
